import { BroadCastCall } from "../broadCast/BroadCastCall";
import { MessageBlock } from "../../../../Framework/MQ/MessageBlock";
import { SSeqAttributeUpdate } from "../../../../Message/Public/SSeqAttributeUpdate";
import { SPassTo } from "../../../../Message/Public/SPassTo";
import { SPoint } from "../../../../Message/Public/SPoint";
import { EEntityAttribute } from "../../../../Message/Public/EEntityAttribute";
import { Log } from "../../../../com/gengine/debug/Log";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { ServerCommand } from "../../mvc/ServerCommand";
//class PositionUpdateCommand
    
    export  class PositionUpdateCommand extends BroadCastCall
    {
        constructor(arg1: Object)
        {
            super(arg1);
            return;
        }

        public /* override */ call(arg1: MessageBlock): void
        {
            var loc2=null;
            var loc1=arg1.messageBase as SSeqAttributeUpdate;
            var loc3;
            (loc3 = new SPassTo()).toPoint = new SPoint();
            loc3.passToId = loc1.code;
            var loc4=0;
            var loc5=loc1.updates;
            label307: for(loc2 of loc5) 
            {
                var loc6=loc2.attribute.__value;
                switch (loc6) 
                {
                    case EEntityAttribute._EAttributeSpaceId:
                    {
                        loc3.mapId = loc2.value;
                        continue label307;
                    }
                    case EEntityAttribute._EAttributePointX:
                    {
                        loc3.toPoint.x = loc2.value;
                        continue label307;
                    }
                    case EEntityAttribute._EAttributePointY:
                    {
                        loc3.toPoint.y = loc2.value;
                        continue label307;
                    }
                    case EEntityAttribute._EAttributeProxyId:
                    {
                        loc3.proxyId = loc2.value;
                        continue label307;
                    }
                    case EEntityAttribute._EAttributeServerId:
                    {
                        loc3.serverId = loc2.value;
                        continue label307;
                    }
                }
            }
            Log.debug("mapPassTo:  " + loc3.toPoint.x + ":" + loc3.toPoint.y);
            Dispatcher.dispatchEvent(new DataEvent(ServerCommand.MapPointUpdate, loc3));
            return;
        }

        private /* var */_passTo: SPassTo;
    }
